Format strings for Date, Time, and DateTime values

The following characters are used to create format strings for Date, Time, and DateTime values:

Character Comments

d

day of month without leading zero for single digits

dd

day of month with leading zero for single digits.

ddd

day of week as a three letter abbreviation

dddd

full name of day of week

M

month without leading zero for single digit

MM

month with leading zero for single digit

MMM

month as three letter abbreviation.

MMMM

full name of month

yy

last two digits of year

yyyy

full four digits of year

h

hours without leading zeros for single digits (12 hour)

hh

hours without leading zeros for single digits (12 hour).

H

hours without leading zeros for single digits (24 hour)

HH

hours with leading zeros for single digits (24 hour)

m

minutes without leading zeros for single digits

mm

minutes with leading zeros for single digits

s

seconds without leading zeros for single digits

ss

seconds with leading zeros for single digits

t, tt

single character or multiple character a.m./p.m. string

The following table illustrates how format strings can affect different Date, Time, and DateTime values being converted by the ToText or CStr function:

Date, Time, or DateTime value Format String Resulting String

CDate(1996, 11, 1)

yy MMM dd, dddd

96 Nov 01, Monday

CTime(12, 10, 10)

HH*mm*ss tt

12*10*10

CDateTime(1995, 10, 12, 3, 30, 11)

HH:mm, yy MMMM ddd

03:30, 96 October Mon

CTime(13, 20, 22)

hh "h" mm "min" ss "sec" tt

01 h 20 min 22 sec

CDate(1998, 3, 17)

M/dd/yy

3/17/98



Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com